const express = require('express'),
app = express();

/**
 * 中间件 是在请求前能做事情
 */

var myLogger = function (req, res, next) {
  console.log('LOGGED')
  next()
}

app.use(myLogger)
 var requestTime = function (req, res, next) {
  req.requestTime = Date.now()
  next()
}

app.use(requestTime)

app.get('/', (req, res) => {
  let responseText = 'Hello world</br>';
  responseText += `<small>Request at: ${req.requestTime}</small>`
  res.send(responseText)
})

app.listen(3000)
